import { PageDateSelect } from '@/types/pages/enum';
import { IFinance} from '@/types/pages/finance/interface';
import Mock from 'mockjs'
import { IDateLineChart, IDatePieChart } from '@/types/echart';

export const getTotalIncomeData: (type: PageDateSelect, date?: Date) => Promise<IFinance> = function (type: PageDateSelect, date?: Date) {
    return new Promise((res, rej) => { 
        let data = {name:'成本',totalNum:Mock.mock('@integer(10000, 50000)'),   unit: '万元', num: Mock.mock('@integer(10000, 50000)'), saleRate: '5%', 'upDownStatus': Mock.mock('@boolean') ,comparisonText:'比去年'}
     
        res(Mock.mock(data));
    })

}
export const getTotalProfitData: (type: PageDateSelect, date?: Date) => Promise<IFinance> = function (type: PageDateSelect, date?: Date) {
    return new Promise((res, rej) => {
        let data = {name:'费用',totalNum:Mock.mock('@integer(10000, 50000)'),   unit: '万元', num: Mock.mock('@integer(10000, 50000)'), saleRate: '5%', 'upDownStatus': Mock.mock('@boolean') ,comparisonText:'比去年'}
     
        res(Mock.mock(data));
    })

}

export const getIncomeData: (type: PageDateSelect, date?: Date) => Promise<IFinance> = function (type: PageDateSelect, date) {
    return new Promise((res, rej) => {
        let data = {name:'其他成本',totalNum:Mock.mock('@integer(10000, 50000)'),   unit: '万元', num: Mock.mock('@integer(10000, 50000)'), saleRate: '5%', 'upDownStatus': Mock.mock('@boolean') ,comparisonText:'比去年'}
        res(Mock.mock(data)); 
    })
}

export const getPieIncomeTypeChart: (type: PageDateSelect, date?: Date) => Promise<IDatePieChart> = function (type: PageDateSelect, date) {
    return new Promise((res, rej) => {
        const dataset:IDatePieChart={title:'成本类型',dataset:{dimensions:['名称','类型'],'source':[{'名称':'榆林化学'+Mock.Random.cname(),'类型|1-100':100,},{'名称':'产品'+Mock.Random.cname(),'类型|1-100':100,},{'名称':'聚酯级'+Mock.Random.cname(),'类型|1-100':100,}]}}
        res(Mock.mock(dataset)); 
    })
}

export const getProfitData: (type: PageDateSelect, date?: Date) => Promise<IFinance> = function (type: PageDateSelect, date) {
    return new Promise((res, rej) => {
        let data = {name:'期间费用',totalNum:Mock.mock('@integer(10000, 50000)'),   unit: '万元', num: Mock.mock('@integer(10000, 50000)'), saleRate: '5%', 'upDownStatus': Mock.mock('@boolean') ,comparisonText:'比去年'}
        res(Mock.mock(data)); 
    })
}

export const getPieIProfitTypeChart: (type: PageDateSelect, date?: Date) => Promise<IDatePieChart> = function (type: PageDateSelect, date) {
    return new Promise((res, rej) => {
        const dataset:IDatePieChart={title:'费用构成',dataset:{dimensions:['名称','类型'],'source':[{'名称':'榆林化学'+Mock.Random.cname(),'类型|1-100':100,},{'名称':'聚酯级'+Mock.Random.cname(),'重量|1-100':100,},{'名称':'聚酯级'+Mock.Random.cname(),'类型|1-100':100,}]}}
        res(Mock.mock(dataset)); 
    })
}

export const getIncomeLineChart:(ype:PageDateSelect,date?:Date)=>Promise<IDateLineChart>=function(type:PageDateSelect,date){
    return new Promise((res,rej)=>{
      const a=()=>(Math.random()*100).toFixed(2)
      const dataset:IDateLineChart={title:'成本趋势（万元）',dataset:{dimensions:['date','实际','预测'],source:[{'date':'2021-01-7','实际':a(),'预测':a()},{'date':'2021-01-8','实际':a(),'预测':a()}]}}
      res(Mock.mock(dataset));
    }) 
}

export const getProfitLineChart:(ype:PageDateSelect,date?:Date)=>Promise<IDateLineChart>=function(type:PageDateSelect,date){
    return new Promise((res,rej)=>{
      const a=()=>(Math.random()*100).toFixed(2)
      const dataset:IDateLineChart={title:'费用趋势（万元）',dataset:{dimensions:['date','实际','预测'],source:[{'date':'2021-01-7','实际':a(),'预测':a()},{'date':'2021-01-8','实际':a(),'预测':a()}]}}
      res(Mock.mock(dataset));
    }) 
}


 
 